<?php
	class Model_tour extends CI_Model{
		protected $_table = "tbl_tours";
		protected $_album = "tbl_albums";
		protected $_votes  = "tbl_votes";
		protected $_vote_track  = " tbl_votes_track";
		protected $_restaurant  = " tbl_restaurants";
		protected $_rooms  = " tbl_rooms";		
		protected $_cago = "tbl_categories";	
		protected $_cruise = "tbl_cruises";	
		protected $_hottel = "tbl_hottels";
		protected $_regions = "tbl_regions";
		public function __construct(){
			parent::__construct();
			$this->load->database();
		}
		public function count_all($id){
			$this->db->where("cago_id",$id);
			return $this->db->count_all_results($this->_table);
		}
		public function list_all($id,$off,$start){
			$this->db->where("cago_id",$id);
			$this->db->limit($off,$start);
			return $this->db->get($this->_table)->result_array();
		}
		public function count_all_cate($id){
			$this->db->where("cate_id",$id);
			return $this->db->count_all_results($this->_table);
		}
		public function list_all_cate($id,$off,$start){
			$this->db->where("cate_id",$id);
			$this->db->limit($off,$start);
			return $this->db->get($this->_table)->result_array();
		}
		public function count_all_hottel($id){
			$this->db->where("cate_id",$id);
			return $this->db->count_all_results($this->_hottel);
		}
		public function list_all_hottel($id,$off,$start){
			$this->db->where("cate_id",$id);
			$this->db->limit($off,$start);
			return $this->db->get($this->_hottel)->result_array();
		}
		public function count_all_cruise($id){
			$this->db->where("cate_id",$id);
			return $this->db->count_all_results($this->_cruise);
		}
		public function list_all_cruise($id,$off,$start){
			$this->db->where("cate_id",$id);
			$this->db->limit($off,$start);
			return $this->db->get($this->_cruise)->result_array();
		}
		public function photos($id){
			$this->db->where("cate_id",$id);
			$this->db->limit(1);
			return $this->db->get($this->_album)->row_array();
		}
		public function hottour(){
			$this->db->where("tour_status","1");
			$this->db->where("tour_show","1");
			$this->db->limit(5);
			return $this->db->get($this->_table)->result_array();
		}
		public function get_categories($cate_id){
			$this->db->where("cate_id",$cate_id);
			return $this->db->get($this->_cago)->result_array();
		}
		public function listtour($id){
			$this->db->where("cate_id",$id);
			$this->db->limit(10);
			return $this->db->get($this->_table)->result_array();
		}
		public function listcruise($id){
			$this->db->where("cate_id",$id);
			return $this->db->get($this->_cruise)->result_array();
		}
		public function listhottel($id){
			$this->db->where("cate_id",$id);
			return $this->db->get($this->_hottel)->result_array();
		}
		public function gettour($id){
			$this->db->where("tour_id",$id);
			return $this->db->get($this->_table)->row_array();
		}
		public function getcruise($id){
			$this->db->where("cruise_id",$id);
			return $this->db->get($this->_cruise)->row_array();
		}
		public function getcago($id){
			$this->db->where("cago_id",$id);
			return $this->db->get($this->_cago)->row_array();
		}
		public function gethottel($id){
			$this->db->where("hottel_id",$id);
			return $this->db->get($this->_hottel)->row_array();
		}
		public function related($cate_id,$tour_id,$id_name,$table){
			$this->db->where($id_name." !=",$tour_id);
			$this->db->where("cate_id",$cate_id);
			$this->db->limit(10);
			return $this->db->get($table)->result_array();
		}
		public function related_show($id,$type,$table){
			$this->db->where("cate_id",$id);
			$this->db->where($type,"1");
			$this->db->limit(5);
			return $this->db->get($table)->result_array();
		}
		public function regions($id){
			$this->db->where("cate_id",$id);
			return $this->db->get($this->_regions)->result_array();
		}
		public function restaurants($id){
			$this->db->where("cate_id",$id);
			return $this->db->get($this->_restaurant)->result_array();
		}
	}